package ExpediaTest;

/**
 * I created this class for StringBuffer capacity test. We can keep on
 * increasing the length of StringBuffer until we get Java out of memory error.
 * This class will fail with below error.
 * 
 * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at
 * java.util.Arrays.copyOf(Arrays.java:2882) at java.lang.AbstractStringBuilder
 * .expandCapacity(AbstractStringBuilder.java:100) at
 * java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390) at
 * java.lang.StringBuffer.append(StringBuffer.java:224) at
 * ExpediaTest.ExpediaQuestion.main(ExpediaQuestion.java:18)
 * 
 * @author Sachin Takkar
 * 
 */
public class StringBufferCapacity {

	/**
	 * Testing with main method
	 * 
	 * @param args
	 */
	public static void main(String args[]) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i <= Math.pow(2, 30) -8; i++) {
			sb.append("A");
		}
		System.out.println(sb);
	}
}
